function isTypeNumber(type, code) {
    var tip = isCredentials(type, code);
    if (tip != "") {
        $("#error").text(tip).css("color", "red");
        return false;
    }
    return true;
}
$(function () {
    getUrl("register/baseInfm", "register/ADdetailInfm");
    //三级联动的默认样式
    $("#distpicker5").distpicker({
        autoSelect: false
    });
    //实时监控输入框
    inputChange(".realName","#nameError");
    inputChange("#typeNumber","#error");
    $("#submitForm").click(function () {
        var realName = $(".realName").val();
        var type = $("#type").val();
        var credentialsNum = $("#typeNumber").val();

        var education = $("#education").val();
        var maritalStatus = getRadioValue("marry");
        var children = getRadioValue("child");
        //三级联动城市
        var province = $("#province9").val();
        var city = $("#city9").val();
        var district = $("#district9").val();
        var area = province + "-" + city + "-" + district;

        var house = getRadioValue("house");
        var car = getRadioValue("car");

        var income = $("#income").val();
        if (!isNotEmpty(realName)) {
            validateSpanMsg("nameError","请输入真实姓名");
            return false;
        } else if (!isRealName(realName)) {
            validateSpanMsg("nameError","真实姓名格式错误");
            return false;
        }else if (!isTypeNumber(type, credentialsNum)) {
            validateSpanMsg("error","证件号码输入有误");
            return false;
        } else {
            var cookie = new sweetCookie();
            var user = JSON.parse(decodeURIComponent(decodeBase64(cookie.getCookie("r_user"), 3)));
            user.realName = realName;
            user.credentialsType = type;
            user.credentialsNum = credentialsNum;
            user.education = education;
            user.monthlyIncome = income;
            user.maritalStatus = maritalStatus;
            user.children = children;
            user.area = area;
            user.house = house;
            user.car = car;
            cookie.setCookie("r_user", encodeBase64(encodeURIComponent(JSON.stringify(user)), 3), 30 * 60000);
            window.location.href = "/Lvscore_User_M/userWeb/views/register/ADdetailInfm.html";
        }
    });
    $("#type").change(function () {
        var type = $("#type").val();
        var credentialsNum = $("#typeNumber").val();
        if (isNotEmpty(credentialsNum)) {
            if (isTypeNumber(type, credentialsNum)) {
                $("#error").text("证件号码校验成功").css("color", "green");
            }
        }
    });
    $("#typeNumber").blur(function () {
        var type = $("#type").val();
        var credentialsNum = $("#typeNumber").val();
        if (isTypeNumber(type, credentialsNum)) {
            $("#error").text("证件号码校验成功").css("color", "green");
        }
    });

});